# $Id$
# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: damir <damir@archlinux.org>

pkgname=x11vnc
epoch=1
pkgver=0.9.14
pkgrel=3
pkgdesc='VNC server for real X displays'
url='https://github.com/LibVNC/x11vnc'
arch=('i686' 'x86_64')
license=('GPL2')
optdepends=('tk: GUI support'
            'net-tools: -auth guess'
            'xf86-video-dummy: Xdummy script')
depends=('libvncserver' 'openssl' 'libjpeg' 'libxtst' 'libxinerama'
         'libxdamage' 'libxrandr' 'avahi' 'xorg-xdpyinfo')
source=("https://github.com/LibVNC/x11vnc/archive/${pkgver}.tar.gz"
        'fix-buffer-overflows.patch'
        '0001-Fix-openssl-1.1.x-detection.patch'
        '0002-Support-openssl-1.1.0.patch'
        'service')
sha256sums=('45f87c5e4382988c73e8c7891ac2bfb45d8f9ce1196ae06651c84636684ea143'
            '1d19edf54c6216b830150e5b05175a81ee8be3288d8584d3de0276df9a38384e'
            'f356009176a11a793fef4514b26468c04908c961e6be226a83b631b6df5a2fdc'
            'f9cafe56cb878b067bc95c6bd84aa8d480af6400bea836d87a08e24e0c4eca0b'
            'cfb19d44e09e960e2fdb958c9258bccf23c2677715314985f7e819f1dcedb6e4')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	patch -p1 -i ../fix-buffer-overflows.patch
        patch -p1 -i ../0001-Fix-openssl-1.1.x-detection.patch
        patch -p1 -i ../0002-Support-openssl-1.1.0.patch
        autoreconf -fi
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	./configure --prefix=/usr --mandir=/usr/share/man
	make
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install
	install misc/{rx11vnc,Xdummy} "${pkgdir}"/usr/bin
	install -Dm644 ../service "${pkgdir}/usr/lib/systemd/system/x11vnc.service"
}
